using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

//UI Ctrl层: UI_Room
public class UI_Room : UGUICtrl
{
    public UI_Room_View selfView;

    public UI_Room()
    {
        OnCreate(ref selfView,"UGUI/ui_room","UI_Room");
    }

    /// <summary>
    /// 按钮添加事件
    /// </summary>
    protected override void ButtonAddClick()
    {
        //------------------按钮添加事件-----------------
        selfView.btn_createRoom.onClick.AddListener(() =>
        {
            Game.GetComp<UNetworkManager>().StartHost();
            OpenNewPanel();
        });
        selfView.btn_connect.onClick.AddListener(() =>
        {
            Game.GetComp<UNetworkManager>().ConnectServer();
            OpenNewPanel();
        });
    }

    void OpenNewPanel()
    {
        ClosePanel();
        Game.UI.OpenUI<UI_Shot>();
        Game.UI.OpenUI<UI_Hurt>();
        Game.UI.OpenUI<UI_Battle>();
    }
    
    /// <summary>
    /// 打开面板
    /// </summary>
    public override void OpenPanel(object data)
    {
        base.OpenPanel(data);
        
    }
    
}